package com.pdool.game.dict;

import com.pdool.game.cache.AbsConfigCache;
import com.pdool.game.dict.vo.DropVo;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class DropConfig extends AbsConfigCache<Integer, DropVo> {

    public DropConfig() {
        super("掉落表_drop_out.xlsx",3);
    }


    @Override
    protected DropVo convert2Value(Map<Integer, String> rowData) {
        int id = Integer.parseInt(rowData.get(1));
        int type = Integer.parseInt(rowData.get(2));
        String name = rowData.get(4);
        int probability = Integer.parseInt(rowData.get(5));
        int num = Integer.parseInt(rowData.get(6));
        String content = rowData.get(6);
        DropVo build = DropVo.builder().id(id)
                .type(type)
                .name(name)
                .probability(probability)
                .num(num)
                .content(content)
                .build();

        return build;
    }

    @Override
    protected Integer convert2Key(Map<Integer, String> rowData) {
        String s = rowData.get(1);
        return Integer.valueOf(s);
    }
}
